/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.jctc.els.modules.biz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import javax.validation.Valid;

import org.jctc.els.modules.biz.entity.Config;
import org.jctc.els.modules.biz.service.config.IConfigService;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

import org.springblade.core.boot.ctrl.BladeController;

import java.time.LocalDateTime;

/**
 *  控制器
 *
 * @author Blade
 * @since 2022-01-14
 */
@RestController
@AllArgsConstructor
@RequestMapping("blade-config/config")
@Api(value = "", tags = "接口")
public class ConfigController extends BladeController {

	private IConfigService configService;


	/**
	 * 分页
	 */
	@GetMapping("/list")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "分页", notes = "传入config")
	public R<IPage<Config>> list() {
		IPage<Config> pages = configService.selectConfigPage();
		return R.data(pages);
	}



	/**
	 * 修改
	 */
	@PostMapping("/update")
	@ApiLog("控制器修改")
	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "修改", notes = "传入config")
	public R update(@Valid @RequestBody Config config) {
		config.setUpdatetime(LocalDateTime.now());
		return R.status(configService.update(config));
	}

}
